﻿<p>
    This example shows how to bind Telerik Grid for ASP.NET MVC to web services.
</p>
<p>
    You need to configure the grid by using the <strong>WebService</strong> method
</p>
<pre class="prettyprint">
&lt;%= Html.Telerik().Grid&lt;Order&gt;()
        .Name("AsmxGrid")
        <em>.WebService(webService => webService.Url("~/Models/Orders.asmx/GetOrders"))</em>
        .Columns(columns =>
        {
           columns.Add(o => o.OrderID).Width(81);
           columns.Add(o => o.Customer.ContactName).Width(200);
           columns.Add(o => o.ShipAddress);
           columns.Add(o => o.OrderDate).Format("{0:MM/dd/yyyy}").Width(100);
        })
        .Sortable()
        .Pageable()
        .Filterable()
        .Scrollable()
%&gt;
</pre>
<p>
    The web service may return the <strong>GridModel</strong> object or any other object which has a <strong>Data</strong> and <strong>Total</strong>
    properties. To benefit from the built-in Linq expression engine you can use the <strong>ToGridModel</strong> extension method:
<pre class="prettyprint">
[WebMethod]
public <em>GridModel&lt;Order&gt;</em> GetOrders(int page, int size, string orderBy, string filter)
{
    NorthwindDataContext northwind = new NorthwindDataContext();

    return northwind.Orders.<em>ToGridModel</em>(page, size, orderBy, filter);
}
</pre>
</p>